<?php

require_once('Adept/Filter/IFilter.php');

class Adept_Filter_Dispatching implements Adept_Filter_IFilter 
{

    protected $response;
    protected $request;
    protected $dispatchers;

    public function __construct() 
    {
    }

    public function process($chain) 
    {
        $this->request = Adept_Context::getInstance()->getRequest();
        $this->response = Adept_Context::getInstance()->getResponse();
        
        Adept_ClassKit_Delegate_List::invokeChain($this->dispatchers, array($this->request, $this->response));
        $chain->next();
    }

    public function add($dispatcher) 
    {
        $this->dispatchers[] = new Adept_ClassKit_Delegate($dispatcher, 'dispatch');
    }

}
